package net.csiit.platform.codeguard.agent;

/**
 * @author adam
 * @date 2020/7/3
 */
public class BeforeSpringBootStart {

    public void beforeMainMethodRunnerStart() {
        net.csiit.platform.codeguard.classloader.ClassLoaderFactory factory = net.csiit.platform.codeguard.classloader.ClassLoaderFactory.getInstance();
        try {
            net.csiit.platform.codeguard.classloader.DecryptSpringBootClassLoader loader = factory.getOrCreateClassLoader();
            Thread.currentThread().setContextClassLoader(loader);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("Can not create decrypt class loader !", e);
        }
    }

    public void beforeSimpleMetadataReader() {
//        if (resource != null) {
//            resource = net.csiit.platform.codeguard.spring.classreading.DecryptResourceWrapper.getResource(resource);
//        }
    }

/*
    public void afterConfigurationClassParserConstructor() {
        try {
            net.csiit.platform.codeguard.classloader.ClassLoaderFactory factory = net.csiit.platform.codeguard.classloader.ClassLoaderFactory.getInstance();
            net.csiit.platform.codeguard.classloader.DecryptSpringBootClassLoader loader = factory.getOrCreateClassLoader();
            net.csiit.platform.codeguard.spring.classreading.DecryptResourceLoader decryptResourceLoader = new net.csiit.platform.codeguard.spring.classreading.DecryptResourceLoader(loader);
            this.resourceLoader = decryptResourceLoader;
            this.metadataReaderFactory = new net.csiit.platform.codeguard.spring.classreading.ConcurrentReferenceCachingMetadataReaderFactory(decryptResourceLoader);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }

    */
}
